package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SealTypeInUnit;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ISealTypeInUnitService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单位内的印章类型Controller
 * 
 * @author ess
 * @date 2021-10-18
 */
@RestController
@RequestMapping("/system/sealTypeUnit")
public class SealTypeInUnitController extends BaseController
{
    @Autowired
    private ISealTypeInUnitService sealTypeInUnitService;

    /**
     * 查询单位内的印章类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:sealTypeUnit:list')")
    @GetMapping("/list")
    public TableDataInfo list(SealTypeInUnit sealTypeInUnit)
    {
        startPage();
        List<SealTypeInUnit> list = sealTypeInUnitService.selectSealTypeInUnitList(sealTypeInUnit);
        return getDataTable(list);
    }

    /**
     * 导出单位内的印章类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:sealTypeUnit:export')")
    @Log(title = "单位内的印章类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SealTypeInUnit sealTypeInUnit)
    {
        List<SealTypeInUnit> list = sealTypeInUnitService.selectSealTypeInUnitList(sealTypeInUnit);
        ExcelUtil<SealTypeInUnit> util = new ExcelUtil<SealTypeInUnit>(SealTypeInUnit.class);
        return util.exportExcel(list, "单位内的印章类型数据");
    }

    /**
     * 获取单位内的印章类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sealTypeUnit:query')")
    @GetMapping(value = "/{unitSealTypeId}")
    public AjaxResult getInfo(@PathVariable("unitSealTypeId") Long unitSealTypeId)
    {
        return AjaxResult.success(sealTypeInUnitService.selectSealTypeInUnitByUnitSealTypeId(unitSealTypeId));
    }

    /**
     * 新增单位内的印章类型
     */
    @PreAuthorize("@ss.hasPermi('system:sealTypeUnit:add')")
    @Log(title = "单位内的印章类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SealTypeInUnit sealTypeInUnit)
    {
        return toAjax(sealTypeInUnitService.insertSealTypeInUnit(sealTypeInUnit));
    }

    /**
     * 修改单位内的印章类型
     */
    @PreAuthorize("@ss.hasPermi('system:sealTypeUnit:edit')")
    @Log(title = "单位内的印章类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SealTypeInUnit sealTypeInUnit)
    {
        return toAjax(sealTypeInUnitService.updateSealTypeInUnit(sealTypeInUnit));
    }

    /**
     * 删除单位内的印章类型
     */
    @PreAuthorize("@ss.hasPermi('system:sealTypeUnit:remove')")
    @Log(title = "单位内的印章类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{unitSealTypeIds}")
    public AjaxResult remove(@PathVariable Long[] unitSealTypeIds)
    {
        return toAjax(sealTypeInUnitService.deleteSealTypeInUnitByUnitSealTypeIds(unitSealTypeIds));
    }
}
